﻿using System;
using Silver3D.Math;

namespace Silver3D.Graphics
{
    /// <summary>
    /// Represents a translation in 3D space.
    /// </summary>
    public class TranslationTransform : MatrixTransform
    {
        private Vec3 translation = Vec3.Zero;

        /// <summary>
        /// The 3D translation vector.
        /// </summary>
        public Vec3 Translation
        {
            get { return translation; }
            set
            {
                translation = value;
                IsDirty = true;
            }
        }

        public TranslationTransform(Scene scene, string id)
            : base(scene, id)
        {
        }

        public TranslationTransform(Scene scene, string id, Node parent)
            : base(scene, id, parent)
        {
        }

        public TranslationTransform(Scene scene, string id, Node parent, Vec3 translation)
            : base(scene, id, parent)
        {
            Translation = translation;
        }

        /// <summary>
        /// Updates the MatrixTransform:CachedMatrix member to a translation matrix.
        /// </summary>
        protected override void UpdateMatrix()
        {
            CachedMatrix = Matrix44.CreateTranslation(translation);
        }
    }
}
